<template >
    <div>
        <!-- 面包屑 -->
        <div class="mbx">
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item>权限管理</el-breadcrumb-item>
                <el-breadcrumb-item>权限列表</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <!-- table  -->
        <div class="tab-box">
            <el-table :data="getNum" border style="width: 100%" stripe>
                <el-table-column type="index" label="#">
                </el-table-column>
                <el-table-column prop="authName" label="权限名称" width="396">
                </el-table-column>
                <el-table-column prop="path" label="路径" width="396">
                </el-table-column>
                <el-table-column prop="level" label="权限等级" width="396">
                    <template slot-scope="scope">
                        <el-tag v-show="scope.row.level == 0">一级</el-tag>
                        <el-tag type="success" v-show="scope.row.level == 1">二级</el-tag>
                        <el-tag type="warning" v-show="scope.row.level == 2">三级</el-tag>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <!-- 分页  -->
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pagenum"
            :page-sizes="[5, 10, 15, 20]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>


    </div>
</template>
<script>
import { getrights } from "../api/api"
export default {
    data() {
        return {
            //表格
            tableData: [],
            pagesize:5,
            pagenum:1,
            total:10,
        }
    },
    methods: {

        //请求数据
        permissions() {
            getrights().then(res => {
                console.log(res);
                this.tableData = res.data
                this.total=res.data.length
                console.log(this.total);
            })
        },
        handleSizeChange(val) {
           this.pagesize=val
           
        },
        handleCurrentChange(val){
            this.pagenum=val
        },

    },
    created() {
        this.permissions()
    },
   computed:{
    getNum(){
        return this.tableData.slice((this.pagenum-1)*this.pagesize,this.pagenum*this.pagesize)
    }
   }
}
</script>
<style lang="scss" scoped>
.tab-box {
    margin-top: 15px;
    background-color: #fff;
    padding: 18px 10px;
    box-sizing: border-box;
}
</style>